package com.rtx.edi.gatway.listener.impl;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.rtx.common.EdiConstant;
import com.rtx.edi.gatway.cache.EdiApiDataContext;
import com.rtx.edi.gatway.listener.EdiListener;
import com.rtx.edi.platform.rule.bean.WhseidRule;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.common.service.CommonService;

@Component
public class SkuWhseidRule implements EdiListener{
	
    @Autowired
    private CommonService commonService;

	@Override
	public void doCustom(EdiApiDataContext apiDataContext) {
		List<String> whseidList = commonService.selectActiveWhseidNotEnterprise(WmsConstant.ENTERPRISE);
		apiDataContext.getApiGlobalMap().put(EdiConstant.ACTIVE_MAIN_DATASOURCEKEY, "enterprise");
		apiDataContext.getApiGlobalMap().put(EdiConstant.ACTIVE_SUB_DATASOURCEKEY_LIST, whseidList.stream().filter(temp->!temp.equals("enterprise")).collect(Collectors.joining(",")));
	}

}
